#!/sbin/openrc-run

depend() {
    use net
    after postgresql
}

get_config() {
    [ -f "${CONFFILE}" ] || eend 1 "'${CONFFILE}' not found"
}

start() {
    ebegin "Starting Odyssey"
    get_config
    local ret=$?
    if [ $ret -ne 0 ] ; then
        eend $ret
        exit $ret
    fi
    start-stop-daemon --start \
        --pidfile ${PIDFILE} \
        --user odyssey -b -m \
        --exec /usr/bin/odyssey -- "${CONFFILE}"
    eend $?
}

stop() {
    ebegin "Stopping Odyssey"
    start-stop-daemon --stop \
        --pidfile ${PIDFILE} 
    eend $?
}

reload() {
    ebegin "Reloading Odyssey configuration from '${CONFFILE}'"
    start-stop-daemon --signal HUP --pidfile ${PIDFILE}
    eend $?
}

